package BankAndTicket; /**
 * @author wuhan
 * @date 2019/9/18 22:29
 */

/**
 * 饿汉式
 */
class HungryMan {
    private static  final HungryMan s=new HungryMan();
    private HungryMan(){}
    public static HungryMan getInstance(){
        return s;
    }
}

/**
 * 懒汉式
 */
class LazyMan{
    public static  LazyMan lazyMan = null;

    public LazyMan() {
    }
    public static LazyMan getInstance(){
        if (lazyMan==null){
            synchronized (LazyMan.class){
                if (lazyMan==null){
                    lazyMan=new LazyMan();
                }
            }
        }
        return lazyMan;
    }
}


public class SingleDemo {
    public static void main(String[] args) {

    }
}
